home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-01-22 | 5.2 KB | 224 lines | [TEXT/NISI] |
- # This script is designed to dial a Hayes compatible modem and converse
- # with a Cisco terminal server to establish a SLIP connection. It
- # shouldn't be too hard to adapt to other modems or terminal servers
- # just by changing a few "ifmatch" target strings.
- #
- # You should preset the following parameters by using the "Scan Script"
- # button in the "Variables" dialog.
- #
- # $user -- username to log into the terminal server
- # $phone -- the phone number to dial
- #
- # Using default settings, the modem will be initialized before this script
- # starts running.
-
- # Let the user know we're starting up. Set up a global
- # abort action.
-
- on restart goto restart
- on abort goto abort
- label startup
- message "Script starting..."
-
- # If a password variable is not defined in the connection
- # set, ask for a password to log into the SLIP server.
-
- ifdef password goto noaskp
- message "Will login to SLIP server as $user.\n\bPassword:"
- askp password
- label noaskp
-
- # Dial the phone and wait for the terminal server to send its login
- # banner. Some areas support using *70 as a dialing prefix to suppress
- # call-waiting tones which will probably cause your modem
- # to lose the connection. Some terminal servers may require you to
- # autobaud before they will respond. Allow enough time for the modem
- # handshake to complete.
-
- label redial
- message "Dialing $phone..."
- flush
- on abort goto hangupabort
- send "ATDT $phone\r"
-
- {
- ifmatch "login:" break
- ifmatch "NO DIALTONE" goto nodialtone
- ifmatch "BUSY" goto phonebusy
- ifmatch "NO CARRIER" goto nocarrier
- iftime 1:15 goto dialtimeout
- }
-
- # Log into the terminal server. Try three times to send the username. Use
- # counter #1 to count the number of login attempts.
-
- setcount 1 0
- label login
- ifcountgt 1 3 goto cantlogin
- message "Logging in as $user..."
- setcount 0 0
- label user
- flush
- ifcountgt 0 3 goto baduser
- send "$user\r"
- {
- ifmatch "Password:" break
- ifmatch "login:" goto user
- iftime 10 goto baduser
- }
-
- # Send your password and wait for the ">" prompt. If we see the
- # "Username:" prompt again, then we didn't get logged in so try again.
-
- message "Sending password..."
- flush
- send "$password\r"
- goto setslip
-
- label accessdenied
- {
- ifmatch "login:" goto login
- ifmatch "NO CARRIER" goto cantlogin
- iftime 10 goto cantlogin
- }
- goto cantlogin # Shouldn't get here, but just in case
-
-
- # Setup the slip server. "Terminal download" is Cisco specific. If you're
- # not using a Cisco, replace this section with any commands specific to
- # your slip server.
-
- label setslip
-
- {
- ifmatch "beginning...." break
- iftime 40 goto cantstartslip
- }
- ipfind IPGWADDRESS IPADDRESS
-
- # All done. Send message to alert the user, flush the junk out of the
- # receive buffer, and return success.
-
- message "Script complete"
- flush
- return 1
-
- # Error handlers.
-
- label abort
- beep
- message "\bCommand-. seen or Cancel button clicked."
- goto aborted
-
- label hangupabort
- beep
- message "\bCommand-. seen or Cancel button clicked."
- goto hangup
-
- label cantfindmodem
- beep
- message "\bThe modem didn't respond to attention"
- message "\bbsignal. Check modem and cabling."
- goto aborted
-
- label cantinitmodem
- beep
- message "\bThe modem didn't respond to initialization"
- message "\bstring. Check the modem."
- goto aborted
-
- label nodialtone
- beep
- message "\bThe modem could not detect a dialtone."
- message "\bCheck the phone line."
- goto aborted
-
- label phonebusy
- beep
- message "\bThe number $phone is busy."
- delay 1
- goto redial
-
- label nocarrier
- beep
- message "\bThe modem could not establish a connection."
- message "\bMake sure there is a modem on the other end."
- delay 1
- goto redial
-
- label dialtimeout
- message "\bThe modem or SLIP server isn't responding."
- message "\bTry dialing manually to make sure the modem"
- message "\band SLIP server are OK."
- goto aborted
-
- label baduser
- beep
- message "\bThe SLIP server won't accept a username."
- message "\bTry dialing manually to make sure the SLIP"
- message "\bserver is OK."
- goto hangup
-
- label cantlogin
- beep
- message "\bLogin to SLIP server failed, check username"
- message "\band password."
- goto hangup
-
- label cantsetterm
- beep
- message "\bCan't set terminal line for SLIP operation."
- goto hangup
-
- label cantstartslip
- beep
- message "\bCan't put server into SLIP mode."
- goto hangup
-
- # General back-end for bailing out.
-
- label hangup
- do disconnect
- # fallthrough into aborted
-
- label aborted
- message "\bScript aborted!"
- # This activates the OK button.
- ask junk
- flush
- return 0
-
- # Restart procedure.
- # This label is entered when you click the restart button in the
- # connection dialog. We try to force the modem to hang up, then we go back
- # to the start of the script.
-
- label restart
- do disconnect
- delay 2
- message "\bScript restarted."
- goto startup
-
- # Disconnect procedure. The "disconect" procedure is called by MacSLIP
- # when the "Disconnect" button is clicked. This procedure escapes the
- # modem into command mode and hangs up the phone. The +++ escape sequence
- # is surrounded by delays that some modems require.
-
- label disconnect
- send "\d\d+++\d\dATH\r"
- flush
- return 1
-
- # Alternate disconnect procedure for modems that drop into command mode
- # when DTR is dropped. You may want to try this alternate disconnect
- # procedure if the one above doesn't work for your modem. Just swap the
- # labels to use this one instead of the one above.
-
- label disconnect2
- dtr off
- delay 3
- send "ATH\r"
- dtr on
- flush
- return 1
-